<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
<head>
<%@ include file="/WEB-INF/jsp/include/head.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><html:text name="sys.name" /></title> 
<link rel="stylesheet" href="<%=WEBPATH%>/themes/dafault/xtree.css" type="text/css">
<script type="text/javascript" src="<%=WEBPATH%>/scripts/jquery/jquery.js"></script> 
<script type="text/javascript" src="<%=WEBPATH%>/dwr/engine.js?id=<%=generate%>"></script>
<script type="text/javascript" src="<%=WEBPATH%>/dwr/util.js?id=<%=generate%>"></script>
<script type="text/javascript" src="<%=WEBPATH%>/scripts/xtree/xtree.js"></script>
<script type="text/javascript" src="<%=WEBPATH%>/scripts/xtree/xmlextras.js"></script>
<script type="text/javascript" src="<%=WEBPATH%>/scripts/xtree/xloadtree.js"></script>
<script type="text/javascript" src='<%=WEBPATH%>/dwr/interface/GroupAction.js?id=<%=generate%>'></script>
<script type="text/javascript" src='<%=WEBPATH%>/dwr/interface/GroupBean.js?id=<%=generate%>'></script>
</head>
<body>
<table width="100%" bordercolor="#000000" cellspacing="0" cellpadding="0" border="0" align="center">
	<tr>
		<td width="100" height="500" valign="top">
		<div style="padding-left: 5px;">
			<script type="text/javascript" charset="UTF-8">
					webFXTreeConfig.rootIcon		= "<%=WEBPATH%>/images/xloadtree/page_white_magnify.gif";
					webFXTreeConfig.openRootIcon	= "<%=WEBPATH%>/images/xloadtree/page_white_magnify.gif";
					webFXTreeConfig.folderIcon		= "<%=WEBPATH%>/images/xloadtree/folder.png";
					webFXTreeConfig.openFolderIcon	= "<%=WEBPATH%>/images/xloadtree/openfolder.png";
					webFXTreeConfig.fileIcon		= "<%=WEBPATH%>/images/xloadtree/page_white_gear.gif";
					webFXTreeConfig.lMinusIcon		= "<%=WEBPATH%>/images/xloadtree/Lminus.png";
					webFXTreeConfig.lPlusIcon		= "<%=WEBPATH%>/images/xloadtree/Lplus.png";
					webFXTreeConfig.tMinusIcon		= "<%=WEBPATH%>/images/xloadtree/Tminus.png";
					webFXTreeConfig.tPlusIcon		= "<%=WEBPATH%>/images/xloadtree/Tplus.png";
					webFXTreeConfig.iIcon			= "<%=WEBPATH%>/images/xloadtree/I.png";
					webFXTreeConfig.lIcon			= "<%=WEBPATH%>/images/xloadtree/L.png";
					webFXTreeConfig.tIcon			= "<%=WEBPATH%>/images/xloadtree/T.png";
					webFXTreeConfig.blankIcon		= "<%=WEBPATH%>/images/xloadtree/blank.png";
					var treeDict = new WebFXTree("组",""); 
					<html:iterator value="groupBeans" id="groupBeans">
							treeDict.add(new WebFXTreeItem("<html:property value="groupName"/>","javascript:showCategory('<html:property value="id"/>')","","<%=WEBPATH%>/images/xloadtree/folder.png"));
					</html:iterator> 
					document.write(treeDict);
				</script></div>
		</td>
		<td width="80%" valign="top">
			<table width="100%" bordercolor="#000000" cellspacing="0" cellpadding="0" border="0" align="center">
				<tr>
					<td><html:text name="group.groupName"/><html:hidden id="id" name="id"/></td>
					<td><html:textfield cssClass="x-text"  id="groupName" name="groupName" cssStyle="width:95%" theme="simple"/></td>
				</tr>
				<tr>
					<td><html:text name="group.groupDescn"/></td>
					<td><html:textarea cssClass="x-text"  id="groupDescn" name="groupDescn" cssStyle="width:95%" cols="5" theme="simple"/></td>
				</tr>
				<tr>
					<td colspan="2" align="right">&nbsp;<input class="x-btn"
					id="saveBtn" name="saveBtn" type="button" 
					value=" <html:text name="button.save"></html:text> "
					style="width: 90px" onclick="javascript:saveRole();"></input> &nbsp; &nbsp; &nbsp;<input
					name="deleteBtn" id="deleteBtn" type="button"  class="x-btn"
					value=" <html:text name="button.delete"></html:text> "
					style="width: 90px" onclick="javascript:delRole();"></input>&nbsp; &nbsp; &nbsp;<input
					name="backBtn" id="backBtn" type="button"  class="x-btn"
					value=" <html:text name="button.back"></html:text> "
					style="width: 90px" onclick="javascript:backRole();"></input>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<script type="text/javascript" charset="UTF-8">
	function showCategory(id){
		GroupAction.dwrView(id,updateData);
	}
	function updateData(data){
		jQuery('#id').val(data.id);
		jQuery('#groupName').val(data.groupName);
		jQuery('#groupDescn').val(data.groupDescn);
		jQuery('#deleteBtn').show();
		jQuery('#backBtn').show();
		jQuery('#saveBtn').show();
	}
	function saveRole(){
		var GroupBean={
			id: jQuery('#id').attr("value"),
			groupName: jQuery('#groupName').attr("value"),
			groupDescn: jQuery('#groupDescn').attr("value")
		}
		GroupAction.dwrSave(GroupBean,saveCallBack);
	}
	function saveCallBack(data){
		alert(data);
		window.location="<%=WEBPATH%>/system/group/index.crm";
	}
	function delRole(){
		var id=jQuery('#id').attr("value");
		GroupAction.dwrDelete(id,saveCallBack);
	}
	function init(){
		jQuery('#id').val("");
		jQuery('#groupName').val("");
		jQuery('#groupDescn').val("");
		jQuery('#deleteBtn').hide();
		jQuery('#backBtn').hide();
		jQuery('#saveBtn').show();
	}
	init();
	function backRole(){
		init();
	}
</script>
</body>
</html>